﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace UM_SERVER.Net
{
    class SystemUdpPortListener : UdpPortListener
    {
        public SystemUdpPortListener(int Port, MessageListener messageListener)
            : base(Port, messageListener)
        {
        }

        public override void Init()
        {
            this.PortProcessor = new UdpClient(this.Port);
            ((SystemUdpMessageListener)this.Listener).Udpclient = this.PortProcessor;
            this.Listener.Init();
        }

        public override void Dispose()
        {
            if (this.PortProcessor != null)
            {
                 this.PortProcessor.Close();
            }
            if (this.CurrentThread != null)
            {
                this.CurrentThread.Abort();
            }
        }
    }
}
